package com.xiaomi.back.controller;

import com.github.pagehelper.PageInfo;
import com.xiaomi.back.service.bill.BillBackService;
import com.xiaomi.back.service.billdetailed.BilldetaildeService;
import com.xiaomi.back.service.billdetailed.impl.BilldetaildeServiceImpl;
import com.xiaomi.back.service.user.UserBackService;
import com.xiaomi.pojo.User;
import com.xiaomi.util.Todaytime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/back")
public class BackIndexController {

    @Autowired
    private BilldetaildeServiceImpl billdetaildeService;
    @Autowired
    private UserBackService userBackService;
    @Autowired
    private BillBackService service;

    @RequestMapping("/index")
    public String index(Model model){
        //销售额
        double price=billdetaildeService.DailySales(Todaytime.Todaytime());
        model.addAttribute("price",price);

        //用户
        List<User> userList = userBackService.LoginCount(Todaytime.Todaytime());
        //获取今日登陆用户数量
        int count = userList.size();
        model.addAttribute("count", count);

        //未发货订单
        int Undecount=service.GetUndelivered();
        model.addAttribute("Undecount",Undecount);

        return "back/index";
    }
}
